// JavaScript Document
function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("您的浏览器暂不支持直接收藏，请使用Ctrl+D进行添加");
        }
    }
}

$(function() {
	var obj = $("#goTop");
	var obj1 = $('#go_top');
	var flag = false;
	var logonFlag = true;
	var onlyOne = true;
	var clearTime = null;
	var clearTime2 = null;

	var layoutWidth = 950;
	var goTopLeft = $(window).width() - 80 + "px";
	if ($('#goTopUser').length <= 0) {
		var goTopOffsiteHeight = 0;
	} else {
		var goTopOffsiteHeight = 100;
	}
	var logonPopLeft = logonPopLeft = Math.floor(($(window).width() - layoutWidth) / 2) + 2 + "px";
	if ($.browser.mozilla) {
		logonPopLeft = logonPopLeft = Math.floor(($(window).width() - layoutWidth) / 2) + 1 + "px";
	}
	obj.css("left", goTopLeft);
	
	if ($.browser.msie && $.browser.version == '6.0') {
		obj.css("position", "absolute");
	} else {
		obj.css("top", $(window).height() - 137 - goTopOffsiteHeight + "px");
	}
	obj1.click(function() {
        $(window).scrollTop(0);
    });
	$(window).scroll(function() {
        if ($(window).scrollTop() == 0) {
            obj.fadeOut();
            flag = true;
            logonFlag = true;
        } else if (flag == true) {
            flag = false;
            obj.fadeIn();
        } else if (onlyOne == true) {
            obj.fadeIn();
            onlyOne = false;
        }
        if ($.browser.msie && $.browser.version == '6.0') {
            obj.css('top', $(window).height() + $(window).scrollTop() - 137 - goTopOffsiteHeight + 'px');
            if (clearTime != null) {
                clearTimeout(clearTime);
                obj.css("display", "none");
            }
            if ($(window).scrollTop() > 0) {
                clearTime = setTimeout("$('#goTop').fadeIn('10');", 100);
            }
        }
    });
    $(window).resize(function() {
        if ($.browser.msie && $.browser.version == '6.0') {
            obj.css('top', $(window).height() + $(window).scrollTop() - 137 - goTopOffsiteHeight + 'px');
        } else {
            obj.css("top", $(window).height() - 137 - goTopOffsiteHeight + "px");
        }
        var HalfWidth = $(window).width() - 80 + "px";
        obj.css("left", HalfWidth);
    });
})